/*
 * Frame.java
 *
 * Created on 19 de Abril de 2009, 13:17
 */

package br.uece.comp.paa.gui;

import java.awt.CardLayout;

import javax.swing.JPanel;
import javax.swing.JScrollPane;

import br.uece.comp.paa.gui.action.ApresentarRelatorioAction;
import br.uece.comp.paa.gui.action.CarregarGrafoAction;
import br.uece.comp.paa.gui.action.ExibirGrafoAction;
import br.uece.comp.paa.gui.action.SairAction;
import br.uece.comp.paa.gui.action.SobreAction;

/**
 * 
 * @author juliano
 */
public class PAAFrame extends javax.swing.JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel cards = new JPanel();

	private GrafoPanel grafoPainel = new GrafoPanel();

	private RelatorioAGMPanel relatorioAGMPanel = new RelatorioAGMPanel();

	public enum Painel {
		GRAFO, RELATORIO, ABERTURA, SOBRE
	};

	/** Creates new form Frame */
	public PAAFrame() {
		initComponents();

		cards.setLayout(new CardLayout());
		cards.add(new JScrollPane(grafoPainel), Painel.GRAFO.toString());
		cards.add(new JScrollPane(relatorioAGMPanel), Painel.RELATORIO.toString());
		cards.add(new SobrePanel(), Painel.SOBRE.toString());
		cards.add(new JPanel(), Painel.ABERTURA.toString());

		setContentPane(cards);
		// setPanel(Painel.RELATORIO);
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		jMenuBar = new javax.swing.JMenuBar();
		jMenuArquivo = new javax.swing.JMenu();
		menuItemCarregar = new javax.swing.JMenuItem();
		menuItemSair = new javax.swing.JMenuItem();
		menuGrafo = new javax.swing.JMenu();
		menuItemExibirGrafo = new javax.swing.JMenuItem();
		menuRelatorio = new javax.swing.JMenu();
		menuItemGerarAGM = new javax.swing.JMenuItem();
		jMenuSobre = new javax.swing.JMenu();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("Projeto PAA - Árvore Geradora Mínima");

		jMenuArquivo.setText("Arquivo");

		menuItemCarregar.setAction(new CarregarGrafoAction());
		menuItemCarregar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.CTRL_MASK));
		menuItemCarregar.setText("Carregar Grafo");
		menuItemCarregar.setEnabled(true);
		jMenuArquivo.add(menuItemCarregar);

		menuItemSair.setAction(new SairAction());
		menuItemSair.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
		menuItemSair.setText("Sair");
		menuItemSair.setEnabled(true);
		jMenuArquivo.add(menuItemSair);

		jMenuBar.add(jMenuArquivo);

		menuGrafo.setText("Grafo");

		menuItemExibirGrafo.setAction(new ExibirGrafoAction());
		menuItemExibirGrafo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
		menuItemExibirGrafo.setText("Exibir Grafo");
		menuItemExibirGrafo.setEnabled(true);
		menuGrafo.add(menuItemExibirGrafo);

		jMenuBar.add(menuGrafo);

		menuRelatorio.setText("Relatórios");

		menuItemGerarAGM.setAction(new ApresentarRelatorioAction());
		menuItemGerarAGM.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
		menuItemGerarAGM.setText("Gerar AGM");
		menuItemGerarAGM.setEnabled(true);
		menuRelatorio.add(menuItemGerarAGM);

		jMenuBar.add(menuRelatorio);

		jMenuSobre.setAction(new SobreAction());
		jMenuSobre.setText("Sobre");
		jMenuSobre.setEnabled(true);
		jMenuBar.add(jMenuSobre);

		setJMenuBar(jMenuBar);

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 800, Short.MAX_VALUE));
		layout.setVerticalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 577, Short.MAX_VALUE));

		pack();
	}// </editor-fold>//GEN-END:initComponents

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new PAAFrame().setVisible(true);
			}
		});
	}

	public void setPanel(Painel nome) {
		((CardLayout) cards.getLayout()).show(cards, nome.toString());
	}

	public GrafoPanel getGrafoPanel() {
		return grafoPainel;
	}

	public RelatorioAGMPanel getRelatorioAGMPanel() {
		return relatorioAGMPanel;
	}

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JMenu jMenuArquivo;
	private javax.swing.JMenuBar jMenuBar;
	private javax.swing.JMenu jMenuSobre;
	private javax.swing.JMenu menuGrafo;
	private javax.swing.JMenuItem menuItemCarregar;
	private javax.swing.JMenuItem menuItemExibirGrafo;
	private javax.swing.JMenuItem menuItemGerarAGM;
	private javax.swing.JMenuItem menuItemSair;
	private javax.swing.JMenu menuRelatorio;
	// End of variables declaration//GEN-END:variables

}
